package com.ttg.web.dao.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ttg.model.mapper.VipRattingConfigMapper;
import com.ttg.model.pojo.VipRatingConfig;
import com.ttg.web.dao.VipRattingConfigDao;
import nonapi.io.github.classgraph.json.Id;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhangHongYuan
 * @description
 * @date 2023/6/8 11:20
 */
@Repository
public class VipRattingConfigDaoImpl extends ServiceImpl<VipRattingConfigMapper, VipRatingConfig> implements VipRattingConfigDao {

    @Override
    public int countRules(Integer id) {
        LambdaQueryWrapper<VipRatingConfig> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(VipRatingConfig::getRulesId,id);
        return count(wrapper);
    }

    @Override
    public List<VipRatingConfig> getRattingRulesListByRulesId(String rulesId) {
        LambdaQueryWrapper<VipRatingConfig> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(VipRatingConfig::getRulesId, rulesId);
        wrapper.orderByAsc(VipRatingConfig::getRatingStart);
        return list(wrapper);
    }
}
